package com.example.mydata.service;

import com.example.mydata.Vo.Book;
import com.example.mydata.Vo.BookStatus;
import com.example.mydata.Vo.User;

public class LibraryServiceborrow {
    // 还书逻辑（简单版罚款：超期1天罚款1元）
    public double returnBook(User user, Book book, int overdueDays) {
        if (user.getBorrowedBooks().contains(book)) {
            user.getBorrowedBooks().remove(book);
            book.setStock(book.getStock() + 1);
            book.setStatus(BookStatus.AVAILABLE);
            return Math.max(0, overdueDays * 1.0); // 返回罚款金额
        }
        return 0.0;
    }
}
